﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 控件布局2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }


        /// <summary>
        /// 窗体大小改变的时候调用，可以在这里对控件进行自适应的手工布局
        /// </summary>
        /// <param name="levent"></param>
        protected override void OnLayout(LayoutEventArgs levent)
        {
            base.OnLayout(levent);

            // 获取窗口的大小，仅仅包含客户区域，不包含标题栏
            int w = this.ClientSize.Width;
            int h = this.ClientSize.Height;

            int yoff = 0;

            yoff = 4;

            this.textBox1.Location = new Point(0+yoff, yoff);
            this.textBox1.Size = new Size(w - 100-yoff, 30);

            this.button1.Location = new Point(w - 100, yoff);
            this.button1.Size = new Size(100, 30);

            this.pictureBox1.Location = new Point(0+yoff,30+yoff);
            this.pictureBox1.Size = new Size(w-yoff, 200);







        }
    }
}
